import com.dmotiko.general.*
import com.dmotiko.util.*
import mx.utils.Delegate;

class WebSiteSectionOLD
extends BaseClip {
	
	public static var SHOW_END:String = "websitesection_showend";
	public static var HIDE_END:String = "websitesection_hideend";
	
	private var forward:Function;
	private var rewind:Function;
	private var sName:String;
	private var bShowed:Boolean;
	private var controller:MovieClip;
		
	private function WebSiteSectionOLD(app) {
		super();
		setData(app);
		app.addEventListener( WebSite.SECTION_CHANGED, Delegate.create(this, sectionChanged) );
		MovieEffects.rewind();
		MovieEffects.forward();
	}
	
	private function sectionChanged(evnt) {
		if( getData().getSection() == sName) {
			showSection();
		} else {
			hideSection();
		}
	}
	
	public function isShowed():Boolean {
		return bShowed;
	}
	
	public function showSection() {
		if (bShowed) return;
		//com.dmotiko.chabeli.ChabeliSite.getApp().log("websiteSectionOLD "+sName+" showSection");
		if (controller) controller.stopEffect();
		controller = this.forward( { bind: this, listener: showEnd } );
	}
	
	public function hideSection() {
		if (!bShowed) return;
		//com.dmotiko.chabeli.ChabeliSite.getApp().log("websiteSectionOLD "+sName+" hideSection");
		if (controller) controller.stopEffect();
		controller = this.rewind( { bind: this, listener: hideEnd } );
	}
	
	private function showEnd() {
		bShowed = true;
		dispatchEvent( { target: this, type: SHOW_END } );
	}
	
	private function hideEnd() {
		bShowed = false;
		dispatchEvent( { target: this, type: HIDE_END } );
	}
	
}